import { vmSearchList } from '@/api'
export const vmList = async(pageIndex, innerCode) => {
  const res = await vmSearchList({
    pageIndex,
    pageSize: 10,
    innerCode
  })
  res.data.currentPageRecords.forEach(item => {
    item.node.addr = item.node.addr.split('-').at(-1)
    if (item.vmStatus === 0) {
      item.vmStatus = '未投放'
    } else if (item.vmStatus === 1) {
      item.vmStatus = '运营'
    } else {
      item.vmStatus = '撤机'
    }
  })
  return res.data
}
export const indexMethod = (pageIndex, index) => {
  return pageIndex === 1 ? index + 1 : Number(`${pageIndex - 1}${index}`) + 1
}
export const changeList = (pageIndex, page) => {
  pageIndex = page
  return vmList(pageIndex)
}
// 搜索
export const searchResultFn = (taskCode) => {
  return vmList(1, taskCode)
}
